<template>
	<view class="bg-white" >
		<cu-custom :bgColor="NavBarColor" :isBack="true" backFlag="navigate">
			<block slot="backText">返回</block>
			<block slot="content">报警处理</block>
		</cu-custom>
		<view class="cu-list menu margin-top">
			<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
				<view class="content">
					<text class="text-black title ">用户名称:</text>
				</view>
				<view class="action">
					<text class="text-black title ">{{annotation.userName}}</text>
				</view>
			</view>
			<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
				<view class="content">
					<text class="text-black title ">设备编号:</text>
				</view>
				<view class="action">
					<text class="text-black title ">{{annotation.dtuID}}</text>
				</view>
			</view>
			<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
				<view class="content">
					<text class="text-black title ">采集点:</text>
				</view>
				<view class="action">
					<text class="text-black title ">{{annotation.dpname}}</text>
				</view>
			</view>
			<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
				<view class="content">
					<text class="text-black title ">报警级别:</text>
				</view>
				<view class="action" v-if="annotation.warnLeavel=='1'">
				  <text class="text-black title " style="color: orange;">一级报警</text>
				</view>
				<view class="action" v-if="annotation.warnLeavel=='2'">
				  <text class="text-black title " style="color: red;">二级报警</text>
				</view>
			</view>
			<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
				<view>
					<text class="text-black title ">报警类型:</text>
				</view>
				<view class="action" v-if="annotation.warnType=='001'">
				  <text class="text-black title ">压力超限</text>
				</view>
				<view class="action" v-if="annotation.warnType=='002'">
				  <text class="text-black title ">压力过小</text>
				</view>
				<view class="action" v-if="annotation.warnType=='003'">
				  <text class="text-black title ">压力变化超限</text>
				</view>
				<view class="action" v-if="annotation.warnType=='004'">
				  <text class="text-black title ">温度超限</text>
				</view>
				<view class="action" v-if="annotation.warnType=='005'">
				  <text class="text-black title ">温度过低</text>
				</view>
				<view class="action" v-if="annotation.warnType=='006'">
				  <text class="text-black title ">温度变化超限</text>
				</view>
				<view class="action" v-if="annotation.warnType=='007'">
				  <text class="text-black title ">温度过大</text>
				</view>
				<view class="action" v-if="annotation.warnType=='008'">
				  <text class="text-black title ">流量过小</text>
				</view>
				<view class="action" v-if="annotation.warnType=='009'">
				  <text class="text-black title ">流量变化超限</text>
				</view>
				<view class="action" v-if="annotation.warnType=='010'">
				  <text class="text-black title ">数据异常</text>
				</view>
				<view class="action" v-if="annotation.warnType=='110'">
				  <text class="text-black title ">燃气泄露报警</text>
				</view>
				<view class="action" v-if="annotation.warnType=='101'">
				  <text class="text-black title ">设备交流电掉电</text>
				</view>
				<view class="action" v-if="annotation.warnType=='102'" >
				  <text class="text-black title ">设备门被打开</text>
				</view>
				<view class="action" v-if="annotation.warnType=='103'">
				  <text class="text-black title ">设备电池电压过低</text>
				</view>
				<view class="action" v-if="annotation.warnType=='104'" >
				  <text class="text-black title ">强磁干扰</text>
				</view>
				<view class="action" v-if="annotation.warnType=='114'">
				  <text class="text-black title ">磁干扰检测断线</text>
				</view>
				<view class="action" v-if="annotation.warnType=='105'">
				  <text class="text-black title ">采集器压力超限</text>
				</view>
				<view class="action" v-if="annotation.warnType=='106'">
				  <text class="text-black title ">采集器压力过小</text>
				</view>
				<view class="action" v-if="annotation.warnType=='107'">
				  <text class="text-black title ">采集器温度超限</text>
				</view>
				<view class="action" v-if="annotation.warnType=='108'">
				  <text class="text-black title ">采集器温度过低</text>
				</view>
				<view class="action" v-if="annotation.warnType=='201'">
				  <text class="text-black title ">通信失败</text>
				</view>
			</view>
			<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
				<view class="content">
					<text class="text-black title ">报警时间:</text>
				</view>
				<view class="action">
					<text class="text-black title ">{{annotation.revDate}}</text>
				</view>
			</view>
			<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
				<view class="content">
					<text class="text-black title ">报警时长:</text>
				</view>
				<view class="action">
					<text class="text-black title ">{{annotation.duration}}</text>
				</view>
			</view>
			<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
				<view class="content">
					<text class="text-black title ">报警值:</text>
				</view>
				<view class="action">
					<text class="text-black title ">{{annotation.warnValue}}</text>
				</view>
			</view>

			<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
				<view class="content">
					<text class="text-black title ">报警信息:</text>
				</view>
				<view class="action">
					<text class="text-black title ">{{annotation.txtMessage}}</text>
				</view>
			</view>

			<view class="cu-form-group">
				<view class="title">是否处理:</view>
				<view>
					<radio-group name="type" v-model="myFormData.DealStatus"   @change="radioChange1">
					    <label>
					        <radio style="margin-right:0.2rem ; transform:scale(0.7)" value="1" :checked=true /><text>已处理</text>
					    </label>
					    
					    <label>
					        <radio style="margin-right:0.2rem ; transform:scale(0.7)" value="0" /><text>未处理</text>
					    </label>
					</radio-group>                
				</view>
			</view>

			<view class="cu-form-group" >
				<view class="content">
					<text class="text-black title ">处理说明:</text>
				</view>
				<textarea 
					style="border:solid 1px #3c9cff; border-radius:8px; resize:none; margin-left: 1rem;height:70px;overflow:auto" 
					placeholder-style="position: absolute;left:1.2rem;top:0.7rem" 
					placeholder="请输入处理说明" 
					name="input" 
					v-model="myFormData.DealDetail">
				</textarea>
			</view>
			
			
			
			<view style="padding-top: 1rem;">
				<u-button 
					style="width: 7rem; height: 2rem; margin-top:0rem; background-color:#74D6A7;"
					ripple 
					class="custom-style" 
					@click="onSubmit"
					> 
					提交</u-button>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				NavBarColor:this.NavBarColor,
				annotation:{
					id:"",
				},
				myFormData:{
					id:"",
					DealDetail:"",
					DealStatus:"1",
					Dealer:"",
				},
				goodNumber:null,
				flg:true,
				src:"",
				pic:"",
				userId:"",
				id:"",
	
			}
		},
		onLoad: function (option) {
		    const annItem = JSON.parse(decodeURIComponent(option.item));
			this.annotation = annItem
			console.log('’%%%%%%%%%%%%',this.annotation)
			
			this.myFormData.id=this.annotation.id

		},
		created(){
			console.log("created")
			//this.readOk();
		},
		methods:{

			onSubmit(){
		
				console.log("------------------------------------",this.myFormData)
				
				this.$tip.loading();
				this.$http.put('/three/alarmProcessing',this.myFormData).then(res=>{
					console.log(res)
					this.$tip.loaded();
					if (res.data.success){
						this.$tip.toast('提交成功')
						let pages = getCurrentPages(); // 当前页面
						let beforePage = pages[pages.length - 2]; // 上一页
						uni.navigateBack({
						    success: function() {
						        beforePage.onLoad(); // 执行上一页的onLoad方法
						    }
						});
					}
				}).catch(()=>{
					this.$tip.loaded();
					this.$tip.error('提交失败')
				});
			},
			
			radioChange1: function(evt) {
				this.myFormData.DealStatus=evt.detail.value
			},
			
			
		   
		}
	}
</script>

<style>
</style>